<?php

include './function.php'; 

if($_POST){

	if(!empty($_POST['username']) && !empty($_POST['passwd'])){

		$users = include './user.php';

		foreach ($users as $id => $user) {
			if($user['username']==$_POST['username']){
				if(md5($_POST['passwd'])==$user['passwd']){
					session_start();
					$_SESSION['username']=$user['username'];
					success('./index.php','登录成功');
					$login = 1;
				}else{
					error('./index.php','帐号或者密码不对');
					exit;
				}
			}
		}

		if(!isset($login)){
			error('./index.php','帐号或者密码不对');
		}
	}else{
		error('./index.php','帐号密码不能为空');	
	}
}else{
	error('./index.php','非法登录');
}


 ?>